<?php
namespace App\Models\Relations;

/**
 *
 * @author Joker
 *        
 */
trait ValidateTrait
{
    
    
    public function validated()
    {
        $query = $this->newQuery()->where($this->getKeyName(), $this->getKey());
        
        $this->{$this->getValidatedAtColumn()} = $time = $this->freshTimestamp();
        
        $query->update([$this->getValidatedAtColumn() => $this->fromDateTime($time),$this->getValidateColumn() => $this->is_validate]);
    }
    
    /**
     * Get the name of the "validated at" column.
     *
     * @return string
     */
    public function getValidatedAtColumn()
    {
        return defined('static::VALIDATED_AT') ? static::VALIDATED_AT : 'validated_at';
    }
    
    /**
     * 获取 是否 已审核 字段
     * @return string 
     */
    public function getValidateColumn()
    {
        return defined('static::IS_VALIDATE') ? static::IS_VALIDATE : 'is_validate';
    }
}